<?php 
define('_VIEW_MODEL_','admin');
session_start();
$statu = $_SESSION['statu'];
require_once("../init.php");
$where = "";
$namevalue = "";
$selectstyle = 0;
if(!$statu){
	echo "<script>window.parent.location.href='./index.php'</script>";
}
if(isset($page)){
		$page = intval($page);
	}else{
		$page = 1;
	}
$stat = ($page-1)*$adminusernum;
if(isset($act)&&$act=="upda"){
	$id = intval($id);
	$va = intval($value);
	$nu = $va==0?1:0;
	$db->Execute("update {$telper}bbs_book set stat = $nu where id = $id");
}
if(isset($act)&&$act=="searchuser"){
	$namevalue = $selectvalue;
	$sty = $stylename;
	$selectstyle = $sty;
	if($sty == '1'){
		$where  = "where id = '$namevalue'";
	}
	if($sty == '2'){
		$where  = "where bookname = '$namevalue'";
	}
}

$num  = $db->GetRow("select count(id) from {$telper}bbs_book $where");
$rs= $db->Execute("select * from {$telper}bbs_book $where order by creattime desc");
if(!empty($rs)){
	$bbsinfo = $rs->GetArray();
	foreach($bbsinfo as $k=>$v){
		$num[$v['id']] = count(explode(",",$v['bookmember'])); 
	}
}else{
	$bbsinfo = false;
}
$pageObj = new Page($num['count(id)'],$adminusernum,$smartyObj);
$smartyObj->assign('title',$admintitle);
$smartyObj->assign('adminbbstitle',$adminbbsbook);
$smartyObj->assign('bbsinfo',$bbsinfo);
$smartyObj->assign('num',$num);
$smartyObj->assign('namevalue',$namevalue);
$smartyObj->assign('selectstyle',$selectstyle);
$smartyObj->display("bookbbscont.tpl");
?>